﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text.RegularExpressions;

namespace MatchCounterSoap
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "MatchCounterSoapService" in code, svc and config file together.
    public class MatchCounterSoapService : IMatchCounterSoapService
    {
        public int GetMatches(string text, string pattern)
        {
            int matchCounter = 0;

            Match match = Regex.Match(text, pattern);
            while (match.Success)
            {
                matchCounter++;
                match = match.NextMatch();
            }

            return matchCounter;
        }
    }
}
